<extend name="Home@Base/common" />
<block name="body">
    <div class="span9 page_message">
        <section id="contents"> <include file="Home@Addons/_nav" />
            <div class="tab-content">
                <php> $post_url || $post_url = U('add?model='.$model['id'], $get_param);</php>
                <form class="form-horizontal form-center" method="post" action="{$post_url}" id="form">
                    <div class="form-item cf toggle-title">
                        <label class="item-label"> <span class="need_flag">*</span>员工编号<span class="check-tips"></span></label>
                        <div class="controls">
                            <input type="text" value="{$data.emp_no}" name="emp_no" class="text" placeholder="请填员工编号">
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label"> <span class="need_flag">*</span> 员工姓名 </label>
                        <div class="controls">
                            <input type="text" value="{$data.name}" name="name" class="text" placeholder="请填员工姓名">
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label"> 性别<span class="check-tips"></span></label>
                        <div class="controls">
                            <select name="sex">
                                <option disabled selected value=""></option>
                                <option value="男">男</option>
                                <option value="女">女</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label"> 出生年月<span class="check-tips"></span></label>
                        <div class="controls">
                            <input type="date" value="{$data.birthday}" name="birthday" class="text" placeholder="请填出生年月">
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label"> <span class="need_flag">*</span> 身份证号 </label>
                        <div class="controls">
                            <input type="text" value="{$data.idnum}" name="idnum" class="text" placeholder="请填身份证号">
                        </div>
                    </div>

                    <!--<div class="form-item cf">-->
                        <!--<label class="item-label"> <span class="need_flag">*</span> 用户名 </label>-->
                        <!--<div class="controls">-->
                            <!--<input type="text" value="{$data.account}" name="account" class="text" placeholder="请填用户名">-->
                        <!--</div>-->
                    <!--</div>-->
                    <!--<div class="form-item cf">-->
                        <!--<label class="item-label"> <span class="need_flag">*</span> 初始密码 </label>-->
                        <!--<div class="controls">-->
                            <!--<input type="text" readonly="readonly"  name="password" value='123456' >-->
                        <!--</div>-->
                    <!--</div>-->

                    <div class="form-item cf">
                        <label class="item-label"> <span class="need_flag">*</span>处室<span class="check-tips"></span></label>
                        <div class="controls">
                            <select name="chu_dept_id" id="select_chu_dept" onchange="chuDeptSel()">
                                <option disabled selected value=""></option>
                                <volist name="chu_depts" id="vo">
                                    <option value="{$vo.id}">{$vo.name}</option>
                                </volist>
                            </select>
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label"> 科室<span class="check-tips"></span></label>
                        <div class="controls">
                            <select name="ke_dept_id" id="select_ke_dept"></select>
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label"> <span class="need_flag">*</span>职务<span class="check-tips"></span></label>
                        <div class="controls">
                            <select name="duty_id">
                                <option disabled selected value=""></option>
                                <volist name="duty" id="vo">
                                    <option value="{$vo.id}">{$vo.name}</option>
                                </volist>
                            </select>
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label"> <span class="need_flag">*</span>行政级别<span class="check-tips"></span></label>
                        <div class="controls">
                            <select name="adminLvl_id">
                                <option disabled selected value=""></option>
                                <volist name="adminLvl" id="vo">
                                    <option value="{$vo.id}">{$vo.name}</option>
                                </volist>
                            </select>
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label"> 办公室电话 </label>
                        <div class="controls">
                            <input type="text" value="{$data.office_tel}" name="office_tel" class="text" placeholder="请填办公室电话">
                        </div>
                    </div>
                    <div class="form-item cf">
                        <label class="item-label"> <span class="need_flag">*</span> 手机号码(多个号码分号隔开) </label>
                        <div class="controls">
                            <input type="text" value="{$data.mobile_list}" name="mobile_list" class="text" placeholder="请填手机号码">
                        </div>
                    </div>
                    <div>
                        <input type="hidden" name="id" value="{$data.id}">
                        <input type="hidden" id="input_ke_depts" value="{$ke_depts}">
                    </div>
                    <div class="form-item form_bh" style="width: 40%">
                        <button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal" style="float: left">确 定</button>
                        <button class="btn cancel-btn" id="cancel" style="float: right" name="button_cancel" value=1>取 消</button>
                    </div>
                </form>
            </div>
        </section>
    </div>
</block>

<block name="script">
    <script type="text/javascript">
        function chuDeptSel() {
            var ke_dept_sel = document.getElementById("select_ke_dept");
            var length = ke_dept_sel.options.length;
            if(length > 0) {
                for(var i = 0; i < length; i++) {
                    ke_dept_sel.options.remove(0);
                }
            }
            var chu_sel_val = $('#select_chu_dept').val();
            var ke_depts_json = $('#input_ke_depts').val();
            ke_depts = JSON.parse(ke_depts_json);

            var opt = document.createElement("option");
            opt.text = '';
            opt.value = '';
            ke_dept_sel.options.add(opt);
            for(var i = 0; i < ke_depts.length; i++) {
                if(ke_depts[i].pid != chu_sel_val)
                    continue;
                var opt = document.createElement("option");
                opt.text = ke_depts[i].name;
                opt.value = ke_depts[i].id;
                ke_dept_sel.options.add(opt);
            }
        }
    </script>
</block>